import 'package:dustbin_sort/model/user_profile_entity.dart';

userProfileEntityFromJson(UserProfileEntity data, Map<String, dynamic> json) {
	if (json['user'] != null) {
		data.user = new UserProfileUser().fromJson(json['user']);
	}
	return data;
}

Map<String, dynamic> userProfileEntityToJson(UserProfileEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.user != null) {
		data['user'] = entity.user.toJson();
	}
	return data;
}

userProfileUserFromJson(UserProfileUser data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id']?.toInt();
	}
	if (json['username'] != null) {
		data.username = json['username']?.toString();
	}
	if (json['password'] != null) {
		data.password = json['password']?.toString();
	}
	if (json['profile'] != null) {
		data.profile = new UserProfileUserProfile().fromJson(json['profile']);
	}
	if (json['authorities'] != null) {
		data.authorities = new List<UserProfileUserAuthority>();
		(json['authorities'] as List).forEach((v) {
			data.authorities.add(new UserProfileUserAuthority().fromJson(v));
		});
	}
	if (json['enabled'] != null) {
		data.enabled = json['enabled'];
	}
	if (json['accountNonExpired'] != null) {
		data.accountNonExpired = json['accountNonExpired'];
	}
	if (json['accountNonLocked'] != null) {
		data.accountNonLocked = json['accountNonLocked'];
	}
	if (json['credentialsNonExpired'] != null) {
		data.credentialsNonExpired = json['credentialsNonExpired'];
	}
	return data;
}

Map<String, dynamic> userProfileUserToJson(UserProfileUser entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['username'] = entity.username;
	data['password'] = entity.password;
	if (entity.profile != null) {
		data['profile'] = entity.profile.toJson();
	}
	if (entity.authorities != null) {
		data['authorities'] =  entity.authorities.map((v) => v.toJson()).toList();
	}
	data['enabled'] = entity.enabled;
	data['accountNonExpired'] = entity.accountNonExpired;
	data['accountNonLocked'] = entity.accountNonLocked;
	data['credentialsNonExpired'] = entity.credentialsNonExpired;
	return data;
}

userProfileUserProfileFromJson(UserProfileUserProfile data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id']?.toInt();
	}
	if (json['userId'] != null) {
		data.userId = json['userId']?.toInt();
	}
	if (json['nickname'] != null) {
		data.nickname = json['nickname']?.toString();
	}
	if (json['sex'] != null) {
		data.sex = json['sex']?.toInt();
	}
	if (json['motto'] != null) {
		data.motto = json['motto']?.toString();
	}
	return data;
}

Map<String, dynamic> userProfileUserProfileToJson(UserProfileUserProfile entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['userId'] = entity.userId;
	data['nickname'] = entity.nickname;
	data['sex'] = entity.sex;
	data['motto'] = entity.motto;
	return data;
}

userProfileUserAuthorityFromJson(UserProfileUserAuthority data, Map<String, dynamic> json) {
	if (json['authority'] != null) {
		data.authority = json['authority']?.toString();
	}
	return data;
}

Map<String, dynamic> userProfileUserAuthorityToJson(UserProfileUserAuthority entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['authority'] = entity.authority;
	return data;
}